import { IPSSysBDColSet } from './ipssys-bdcol-set';
import { IPSSysBDColumn } from './ipssys-bdcolumn';
import { IPSSysBDScheme } from './ipssys-bdscheme';
import { IPSSysBDTable } from './ipssys-bdtable';
import { IPSSysBDTableRS } from './ipssys-bdtable-rs';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysBDTableImpl extends PSModelObjectImpl implements IPSSysBDTable {
  protected allpssysbdcolsets: IPSSysBDColSet[] | null = null;

  getAllPSSysBDColSets(): IPSSysBDColSet[] | null {
    if (this.allpssysbdcolsets == null) {
      this.allpssysbdcolsets = this.fillChildListModel(this.M.getAllPSSysBDColSets, 'ba.IPSSysBDColSet') as IPSSysBDColSet[];
    }
    return this.allpssysbdcolsets;
  }

  get allPSSysBDColSets(): IPSSysBDColSet[] | null {
    return this.getAllPSSysBDColSets();
  }

  findPSSysBDColSet(objKey: any): IPSSysBDColSet | null {
    return this.getPSModel5('ba.IPSSysBDColSet', this.getAllPSSysBDColSets(), objKey) as IPSSysBDColSet;
  }

  protected allpssysbdcolumns: IPSSysBDColumn[] | null = null;

  getAllPSSysBDColumns(): IPSSysBDColumn[] | null {
    if (this.allpssysbdcolumns == null) {
      this.allpssysbdcolumns = this.fillChildListModel(this.M.getAllPSSysBDColumns, 'ba.IPSSysBDColumn') as IPSSysBDColumn[];
    }
    return this.allpssysbdcolumns;
  }

  get allPSSysBDColumns(): IPSSysBDColumn[] | null {
    return this.getAllPSSysBDColumns();
  }

  findPSSysBDColumn(objKey: any): IPSSysBDColumn | null {
    return this.getPSModel5('ba.IPSSysBDColumn', this.getAllPSSysBDColumns(), objKey) as IPSSysBDColumn;
  }

  get bDTableType(): 1 | 2 | 3 | 9 {
    return this.M.bDTableType;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get inheritTypeValue(): string {
    return this.M.inheritTypeValue;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  protected majorpssysbdtablerss: IPSSysBDTableRS[] | null = null;

  getMajorPSSysBDTableRSs(): IPSSysBDTableRS[] | null {
    if (this.majorpssysbdtablerss == null) {
      const value = this.M.getMajorPSSysBDTableRSs;
      if (value == null) {
        return null;
      }
      const arrayNode: any[] = value;
      if (arrayNode.length == 0) {
        return null;
      }
      const list: IPSSysBDTableRS[] = [];
      const ipssysbdscheme = this.getParentPSModelObject('ba.IPSSysBDScheme') as IPSSysBDScheme;
      for (let i = 0; i < arrayNode.length; i++) {
        const item = ipssysbdscheme.findPSSysBDTableRS(arrayNode[i]);
        if (item != null) {
          list.push(item);
        }
      }
      this.majorpssysbdtablerss = list;
    }
    return this.majorpssysbdtablerss.length == 0 ? null : this.majorpssysbdtablerss;
  }

  get majorPSSysBDTableRSs(): IPSSysBDTableRS[] | null {
    return this.getMajorPSSysBDTableRSs();
  }

  findMajorPSSysBDTableRS(objKey: any): IPSSysBDTableRS | null {
    return this.getPSModel5('ba.IPSSysBDTableRS', this.getMajorPSSysBDTableRSs(), objKey) as IPSSysBDTableRS;
  }

  get memo(): string {
    return this.M.memo;
  }

  protected minorpssysbdtablerss: IPSSysBDTableRS[] | null = null;

  getMinorPSSysBDTableRSs(): IPSSysBDTableRS[] | null {
    if (this.minorpssysbdtablerss == null) {
      const value = this.M.getMinorPSSysBDTableRSs;
      if (value == null) {
        return null;
      }
      const arrayNode: any[] = value;
      if (arrayNode.length == 0) {
        return null;
      }
      const list: IPSSysBDTableRS[] = [];
      const ipssysbdscheme = this.getParentPSModelObject('ba.IPSSysBDScheme') as IPSSysBDScheme;
      for (let i = 0; i < arrayNode.length; i++) {
        const item = ipssysbdscheme.findPSSysBDTableRS(arrayNode[i]);
        if (item != null) {
          list.push(item);
        }
      }
      this.minorpssysbdtablerss = list;
    }
    return this.minorpssysbdtablerss.length == 0 ? null : this.minorpssysbdtablerss;
  }

  get minorPSSysBDTableRSs(): IPSSysBDTableRS[] | null {
    return this.getMinorPSSysBDTableRSs();
  }

  findMinorPSSysBDTableRS(objKey: any): IPSSysBDTableRS | null {
    return this.getPSModel5('ba.IPSSysBDTableRS', this.getMinorPSSysBDTableRSs(), objKey) as IPSSysBDTableRS;
  }

  get name(): string {
    return this.M.name;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysBDTableImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'ba.IPSBDTable' || cls == 'ba.IPSSysBDTable') return true;
    return super.instanceof(cls);
  }
}
